/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package calculatorws_client_application;

import java.util.Scanner;

/**
 *
 * @author Administrator
 */
public class CalculatorWS_Client_Application {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
         int option;
            do{
                
                Scanner input = new Scanner(System.in);

                System.out.println("1.  Add Two Numbers");
                System.out.println("2.  Multiply Two Numbers");
                System.out.println("0.  Exit");
                System.out.println("Enter Option:");
                
                option = input.nextInt();


                    switch(option){
                        case 0:
                            break;
                        case 1:
                            
                            Scanner scan = new Scanner(System.in);
                            System.out.println("Enter First Number");
                            int i = scan.nextInt();
                            System.out.println("Enter Second Number");
                            int j = scan.nextInt();
                            
                            int addResult = add(i, j);
                            
                            System.out.println("The Result is " + addResult);
                                
                            break;
                        case 2: 
                            
                            Scanner scan1 = new Scanner(System.in);
                            System.out.println("Enter Firt Number");
                            int k = scan1.nextInt();
                            System.out.println("Enter Second Number");
                            int l = scan1.nextInt();
                            
                            int multResult = add(k, l);
                            
                            System.out.println("The Result is " + multResult);
                                
                            break;
                        default:
                            System.out.println("not a valid option");
                            break;
                    }
                }while(option!=0);
        
//        try {
//        int i = 3;
//        int j = 4;
//        int addResult = add(i, j);
//        int multResult = multiply(i,j);
//        System.out.println("Add Result = " + addResult);
//        System.out.println("Multiply Result = " + multResult);
//    } catch (Exception ex) {
//        System.out.println("Exception: " + ex);
//    }

    }

    private static int add(int i, int j) {
        calculatorws_client_application.CalculatorWS_Service service = new calculatorws_client_application.CalculatorWS_Service();
        calculatorws_client_application.CalculatorWS port = service.getCalculatorWSPort();
        return port.add(i, j);
    }

    private static int multiply(int k, int l) {
        calculatorws_client_application.CalculatorWS_Service service = new calculatorws_client_application.CalculatorWS_Service();
        calculatorws_client_application.CalculatorWS port = service.getCalculatorWSPort();
        return port.multiply(k, l);
    }
    
}
